Closed (cannot reproduce)
Project:
Administration menu
Version:
7.x-3.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Apr 2009 at 16:59 UTC
Updated:
2 Nov 2018 at 21:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sunWe need to re-purpose this issue and start with the basic implementation. Functionality is similar to contextual links in D7 core, but we want more. ;)
smk-ka already did some awesome work on this, so we just need to get that reviewed and in shape. Will post a patch soon.
Comment #2
sunYou need to run update.php after applying this patch.
1) The structure of $expand_map looks awkward, and may very well be the cause for duplicated menu links for Field UI for content types.
2) Looks like we could skip MENU_DEFAULT_LOCAL_TASK with this, but OTOH, I originally envisioned that we want to stack dynamic links below the respective "List" task, so other tasks on the same level are not buried within a potentially large list of dynamic links.
3) Plenty of @todos.
Comment #3
sun#631550: Stale + improper logic for MENU_VISIBLE_IN_TREE and MENU_VISIBLE_IN_BREADCRUMB eliminated the need to cater for local tasks and actions. We've got almost 100% clean code now, yay! :)
So this patch needs to be revamped to only merge in router items with dynamic path arguments.
Comment #4
sunStarted to streamline this code.
Text formats are currently not properly handled by (the wrongly named) function admin_menu_local_tasks(), because they are no local tasks.
I'm going to try to investigate whether we cannot totally streamline this code, since all dynamic router paths are properly stored as menu links now. This basically means that the following should get us a full-blown sub-tree for a certain dynamic path:
Comment #5
sunEdited above code snippet: works :)
Comment #6
markus_petrux commentedhmm... while admin_menu_tree() gets a $menu_name argument, this is not passed to hook_admin_menu_map() / hook_admin_menu_map_alter(), so it seems that those that implement these hooks may do their job for an unexpected menu tree (in the case that admin_menu_tree() is invoked for several menu trees)? ...or maybe admin_menu_tree() does not really need the $menu_name argument?
Comment #7
sunActually, the $menu_name belongs to the things the still need to be removed. This dynamic tree expansion relies on router paths in the first place. In D7, also dynamic router paths are stored as menu links, so we just leverage that to retrieve the dynamic menu link tree, regardless of its menu_name.
Work in progress patch for the D7 approach attached... however, endless recursion in admin_menu_merge_tree(), since some expanded paths are not local tasks, but regular menu items, so they do not have a $parent_path, but the current code requires all registered dynamic paths to be keyed by their parent path.
Comment #8
sunResolved the recursion error, removed obsolete helper functions, added plenty of docs.
Comment #9
sunQuick note: If we want to backport this to D6, then we need to backport #631550: Stale + improper logic for MENU_VISIBLE_IN_TREE and MENU_VISIBLE_IN_BREADCRUMB -- pwolanin, the menu system maintainer already agreed that it would be possible to do that.
Comment #10
sunCleaned up field_ui implementation.
Comment #11
sunThis patch requires #742318: Fields are editable regardless of whether an bundle instance exists, missing menu titles, etc. for Drupal core to make any sense.
With this patch, the only remaining problem is that
admin/structure/taxonomy/2/fields/field_image
gets also expanded below
admin/structure/taxonomy/1/fields
Patch contains some debugging code due to that. Still not sure where exactly it goes wrong.
Comment #12
sunStill no luck. Recursion still entered for (translated) paths where it shouldn't happen.
Comment #13
smk-ka commentedAgreed, creating the right expansion parameter set for each item and level is definitely... tricky :(
Fixed the remaining bits.
Comment #14
sunYAY! Works for me :)
We still need to resolve the two related core issues tough:
#742318: Fields are editable regardless of whether an bundle instance exists, missing menu titles, etc.
#744258: admin/structure/taxonomy paths have to use machine_name, not vid
And if anyone is interested in this for D6, the following patch just needs to be backported:
#631550: Stale + improper logic for MENU_VISIBLE_IN_TREE and MENU_VISIBLE_IN_BREADCRUMB
Aside from those, let's also look at the remaining @todos in this patch:
Unless I overlooked an important detail, the named placeholder arguments are immediately destroyed here, and rebuilt dynamically during the tree merging. If that is the case, I'd say we should use anonymous placeholders in the first place?
This becomes more likely in combination with access permission optimizations (see below).
This @todo is most likely obsolete - we need the links in their true hierarchical order.
Since all links we are merging are dynamic items containing placeholders, I can't see to which items this code should apply...?
Actually, _menu_link_translate() does very similar stuff like we do here. But it seems we need a mixture of both.
Tinkered about this for quite some time, but couldn't see a way to avoid it. Thus, let's just remove the @todo?
When going through _menu_item_localize(), then the resulting 'link_title' should be sanitized (and translated).
Most dynamic items are probably located below a parent that is using proper access restrictions - e.g. in this case, admin/config/content/formats is only accessible to users with "administer filters" permission. menu_tree_all_data() should already leave inaccessible items out.
Thus, we could use an early-out return for implementations like this, so we do not even try to merge in those dynamic items.
Actually, filter_formats() will only return those text formats the current user is able to access in D7 (the "administer filters" permission no longer works like a "bypass" permission). So we definitely want to query the available formats ourselves here.
The same probably applies to all or most other implementations - we just need a list of available items. Access is handled elsewhere. And to optimize performance, certain implementations may be skipped entirely by checking a user permission upfront.
Powered by Dreditor.
Comment #15
smk-ka commentedThe idea was to make it as easy as possible for third party module developers to add support for admin menu (DX). A typical implementation of hook_admin_menu_map looks like:
It is immediately clear which argument (or arguments, in case there are multiple) the placeholder %taxonomy_vocabulary in the $map key (or 'parent' or 'hide') refers to. And it allows to copy'n'paste from hook_menu, FTW.
Yes, this should be obsolete.
Well, I asked myself the same :) I can only speculate that may intention back then was to also support additional static menu items, possibly to be able to support grouping of (dynamic) menu items.
At least this part:
seems like duplication, as admin_menu_translate()/_menu_translate() also does this check and returns an empty array. Whether we should use _menu_link_translate() now, I don't know.
The only way I can think of would be to simplify the array passed to the function by directly using $replacements (i.e., the dynamic arguments of the current item) instead. The code is currently mimicking the (rather complicated) format of expand_map because it was merged with the menu item's $item[expand_map], which turned out to be not working. Not sure if this would be easily possible, though.
The title is passed through l() which causes all HTML tags to appear – see theme_admin_menu_links(). This todo has obviously been figured out long time ago and is now obsolete.
Simple user access checks upfront – yes please. For querying only the required data – well, I prefer API simplicity over speed in this case (or, at least as long as the overhead is justified).
Comment #16
sunSince the existing patch already works, I decided to commit the patch as is, so it's easier to track any further changes (in this patch).
Resolves most @todos, but also introduces new ones.
Comment #17
sunAs of now, I assume that the cause for the not contained "Comment fields" and "Comment display" items is the following:
- Node bundle field edit paths are
- Comment bundle field edit paths are
Note the additional "comment/" argument in there.
admin/structure/types/manage/%/comment is not a registered path, so it is neither contained in the regular menu tree, but also not in our dynamic.
Comment #18
smk-ka commentedWe need to adjust the 'parent' attribute from comments to attach the items to a valid parent element, i.e. admin/structure/types/manage/%node_type/fields.
Comment #19
Birous commentedDoes this patch applies to my problem, too?
Comment #20
tim.plunkettI was trying to fix #884032: Add enabled views to the 'Views' menu when I noticed that vocabularies weren't being loaded either.
Taxonomy paths were changed with #744258: admin/structure/taxonomy paths have to use machine_name, not vid, so this patch mirrors those changes.
Comment #21
sunThanks, committed!
#17/#18 still needs work.
Comment #22
tim.plunkettI missed the other reference to taxonomy_vocabulary under field_ui. Sorry for clogging up the issue.
Comment #23
sunThanks! Committed #22 to HEAD.
We still need to resolve dynamic Field UI paths for comments on node types, so back to active.
Comment #24
sunRe-rolled #16 against HEAD.
Comment #25
sunThanks for reporting, reviewing, and testing! Committed #24 to HEAD.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.
Comment #26
sunThe missing expansion of "Comment fields" and "Comment display" still remains.
Attached patch is what I have right now. Contains lots of debugging code, but essentially, %comment_node_type does not get expanded, since we seem to have a general problem of only allowing one dynamic argument per path.
Comment #27
sunStopping here. The cause for all this trouble seems to be http://api.drupal.org/api/drupal/modules--comment--comment.module/functi..., which pretends to be a loader function, but is a _to_arg function in reality. Thus, no node type loaded or returned... not sure whether we can support such horribly broken code.
Nevertheless it might be a good idea to commit the drupal_array_merge_deep() change.
Comment #28
kenorb commentedThe same bug with 6-3.x
After uninstalling menu item still is there.
When trying to remove it, I've got error:
See duplicate as well: #588872: Module menu sctructure persists in Navigation menu after uninstalling
Comment #29
sunComment #31
junedkazi commented#27: admin_menu.dynamic.27.patch queued for re-testing.
Comment #33
johnvNot sure if this is a UX feature, or a performance work-around for #1905144: High load time for admin_menu upon user login/menu refresh.
Marked #1923260: og_menus uselessly included / high server load at log-in as a possible specific use case for this.
Comment #34
truls1502I am sorry for no reply until now.
There are many issues regarding this module admin_menu which is a bit difficult for us to follow up since some of the issues might be already outdated, or is already fixed by the module or any other modules or itself core which means that the problem might no longer need to be fixed.
We can see that the issue has been created for a few years ago, I hope it is okay for you that I am postponing the issue, and give you around two weeks. If you still face the problem, could you tell us the step by step when until you get the error message or what is frustrated you, and a list of modules you are using related to admin_menu and a screenshot that might help us? So it makes us easier to reproduce your issue.
However, after two weeks with no feedback - we will close this issue. So in case, you noticed it after the issue is closed, do not hesitate to reopen it like and fill information which is mentioned above.
So before giving us a feedback, do you mind to test it again with our latest 7.x-3.x-dev?
Thank you for understanding! :)
Comment #35
truls1502This issue has been automatically marked as closed because it has not had recent activity after the last post.
However, if you or someone is still facing the same issue as described to the issue, could you please to re-open the issue by changing the status of the issue, and add an explanation with more details which can help us to reproduce your situation.
Again, thank you for your contributions! :)